package com.bdqn.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@Data
@TableName("sys_role")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
public class Role implements Serializable {
  //多对多
  @ManyToMany(targetEntity = Role.class,fetch = FetchType.LAZY)
  @JoinTable(name = "sys_role_right",joinColumns = {@JoinColumn(name = "rf_role_id")},inverseJoinColumns = {@JoinColumn(name = "rf_right_code")})
  @OrderBy(value = "right_code")
  private Set<Right> rights=new HashSet<Right>(0);
  @Serial
  @TableId(type = IdType.AUTO)
  @TableField("role_id")
  private long roleId;

  @TableField("role_name")
  private String roleName;

  @TableField("role_desc")
  private String roleDesc;

  @TableField("role_flag")
  private long roleFlag;

  @OneToMany(targetEntity = User.class,fetch = FetchType.LAZY,cascade = CascadeType.REMOVE,mappedBy = "role")
  private Set<User> users=new HashSet<User>();
}
